<?php
namespace app\index\controller;

use think\Controller;
//权限的验证
use app\index\model\Admin;
use think\session;
class Comm extends Controller
{
    public function __construct(){
        parent::__construct();
        //登录验证
        indexLogin();
        //这里是权限验证
        //获取当前控制器
        $controller = request()->controller();
        //获取当前方法名
        $action = request()->action();
        //生成标识符
        $name=$controller."_".$action;
        $admin=new Admin();
        //利用管理员id和标识符判断与无此数据
        $bool=$admin->isadmin(Session::get("id"),$name);
        $names=["Index_index","Admin_editmyself","Admin_editroot","Quit_Quit","Admin_colonel","Admin_colonelupdate","Admin_coloneldelete/"];
        if(Session::get('isadmin')==1||in_array($name,$names)) {
            return 1;
        }elseif(!$bool){
            echo "您没有此权限！";
            die();
        }else{
            return 0;
        }
    }
}
